home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Alles Voor Internet / Tout Pour Internet
/
alles voor internet.iso
/
MacInternet™
/
SLIP
/
Tone
/
Hayes_compatible_v1.6
< prev
Wrap
Text File
|
1994-10-19
|
6KB
|
289 lines
#
# really generic hayes script - you need to enter phone number,
# username, etc
#
# You should preset the parameter using
# the "Parameters..." item under the "Script" popup
# menu after selecting this script:
#
# $DisconnectString
# $phone
# $user
# $password
# $PromptForPhoneNumber Must be YES to work (not yes)
# $PromptForUserName Must be YES to work (not yes)
# $PromptForPassword Must be YES to work (not yes)
#
# Let the user know we're starting up. Set up a global
# abort action.
on restart goto restart
on abort goto abort
label startup
# We do this so we can init modem.
setcount 0 0
message "Initializing modem.\n"
label modeminit
flush
send "$INITMODEM\r"
ifcountgt 0 3 goto cantinitmodem
{
ifmatch OK break
iftime 3 goto modeminit
}
if "$PromptForPhoneNumber" ne "YES" goto nextone
# Ask for the phone number.
message " \n\n"
message "\bPlease enter the phone number:"
ask phone
message " \n"
message "Thank you.\n"
label nextone
if "$PromptForUserName" ne "YES" goto nexttwo
# Ask for the username.
message " \n\n"
message "\b Please enter your username:"
ask user
message " \n"
message "Thank you.\n"
label nexttwo
if "$PromptForPassword" ne "YES" goto nextthree
# Ask for a password to log into the SLIP server.
message " \n\n"
message "Contacting SLIP server as $user.\n"
message "\b Please enter your password:"
askp password
message " \n"
message "Thank you.\n"
label nextthree
# Dial the phone and wait for the terminal server
# to send its login banner. Some areas support
# using *70 as a dialing prefix to suppress call-
# waiting tones which will probably cause your modem
# to lose the connection. Some terminal servers
# may require you to autobaud before they will respond.
# Allow enough time for the modem handshake to complete.
message "Dialing $phone..."
flush
on abort goto hangupabort # We're about to go off hook, so use different abort handler.
send "ATDT $phone\r"
{
ifmatch "CONNECT" break
ifmatch "NO DIALTONE" goto nodialtone
ifmatch "BUSY" goto phonebusy
ifmatch "NO CARRIER" goto nocarrier
iftime 1:15 goto dialtimeout
}
message "Waking server..."
setcount 0 0
label wakeserver
flush
ifcountgt 0 10 goto cantwakeserver
delay 5
send "\r"
send "\r"
{
ifmatch "Username:" goto startlogin
iftime 20 goto cantwakeserver
}
# Log into the terminal server. Try three times to
# send the username. Use counter number 1 to count the
# number of login attempts.
label startlogin
setcount 1 0
label login
ifcountgt 1 3 goto cantlogin
message "Logging in as $user..."
setcount 0 0
label user
flush
ifcountgt 0 3 goto baduser
send "$user\r"
{
ifmatch "Password:" break
ifmatch "Username:" goto user
iftime 10 goto baduser
}
# Send your password and wait for the ">" prompt.
# If we see the "Username:" prompt again, then
# we didn't get logged in so try again.
message "Sending password...\n"
flush
send "$password\r"
{
ifmatch ">" goto setslip
ifmatch "Access denied" goto accessdenied
iftime 45 goto cantlogin
}
goto setslip # Shouldn't get here, but just in case.
# If the login attempt fails, we land here. We can
# take whatever action is necessary to get another
# login prompt. In the case of Cisco terminal servers,
# no other action is necessary, so we just look for
# "Username:" immediately. Some systems may require
# a \n to get their attention again. Most recovery
# actions will probably go outside the loop.
label accessdenied
{
ifmatch "Username:" goto login
ifmatch "NO CARRIER" goto cantlogin
iftime 10 goto cantlogin
}
goto cantlogin # Shouldn't get here, but just in case
# Put the terminal line into SLIP mode.
label setslip
message "Setting terminal line for SLIP operation..."
flush
send "term down\r"
{
ifmatch ">" break
iftime 10 goto cantsetterm
}
# Enable SLIP. The SLIP server tells us our MTU in bytes,
# so look for the word "system".
message "Enabling SLIP on server..."
flush
send "slip default\r"
{
ifmatch "system" break
iftime 10 goto cantstartslip
}
ipfind IPADDRESS
set IPGWADDRESS 134.84.101.254
set IPNETMASK 255.255.255.0
# All done. Send message to alert the user,
# flush the junk out of the receive buffer,
# and return success.
message "Script complete"
flush
return 1
# Error handlers.
label abort
beep
message "\bOperation cancelled."
goto aborted
label hangupabort
beep
message "\bOperation cancelled."
goto hangup
label cantfindmodem
beep
message "\bThe modem didn't respond to attention"
message "\bsignal. Check the modem and cable."
goto aborted
label cantinitmodem
beep
message "\bThe modem didn't respond to initialization."
message "\bCheck the modem and cable."
goto aborted
label nodialtone
beep
message "The modem could not detect a dialtone."
message "Check the phone line."
goto aborted
label phonebusy
beep
message "The number $phone is busy."
goto aborted
label nocarrier
beep
message "The modem could not establish a connection."
message "Is $phone the right number?"
goto aborted
label badinitstring
message "This is the wrong script for the modem"
goto hangup
label dialtimeout
message "The modem or SLIP server isn't responding."
message "Try again."
goto aborted
label cantwakeserver
message "The SLIP server isn't responding."
message "Try again."
goto hangup
label baduser
beep
message "The SLIP server won't accept a username."
message "Try again."
goto hangup
label cantlogin
beep
message "Login to SLIP server failed, check username"
message "and password."
goto hangup
label cantsetterm
beep
message "Can't set terminal line for SLIP operation."
goto hangup
label cantstartslip
beep
message "Can't put server into SLIP mode."
goto hangup
# General back-end for bailing out. Make sure we've hung up the phone.
label hangup
send "\d+++\d\d\dATH\r"
delay 2
send $DisconnectString\r
label aborted
message "\bScript aborted."
ask junk # This activates the OK button.
flush
return 0
# Stuff to do when "Disconnect" button is pressed.
label disconnect
send "\d+++\d\d\dATH\r"
delay 2
send $DisconnectString\r
flush
return 1
# Stuff to do when "Restart" button is pressed.
label restart
do disconnect
message "\bScript restarted."
goto startup